<?php
namespace app\api\controller\foodcash;

use app\api\controller\foodcash\Controller;
use app\api\model\foodcash\Pact as PactModel;

/**
 * 预约控制器控制器
 */
class Pact extends Controller
{
    /**
     * 详情
     */
    public function detail($id)
    {
		if ($detail = PactModel::get($id)) {
            return $this->renderSuccess(compact('detail'));
        }
        return $this->renderError('数据不存在');
    }
    
    /**
     * 取消预定
     */
    public function cancel($id)
    {
        $model = PactModel::get($id);
        if($model->status(40)){
            return $this->renderMsg('操作成功');
        }
        $error = $model->getError() ?: '操作失败';
        return $this->renderError($error);
    }
    
    /**
     * 守约操作
     */
    public function keep($id)
    {
        $detail = PactModel::get($id);
        if($detail->status(30)){
            return $this->renderSuccess(compact('detail'));
        }
        $error = $detail->getError() ?: '操作失败';
        return $this->renderError($error);
    }
}
